package com.common.lang;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private int Code;
    private String msg;
    private Object data;
    public static Result success(Object data){
        Result m = new Result();
        m.setCode(200);
        m.setMsg("操作成功");
        m.setData(data);
        return m;
    }
    public static Result success(String msg,Object data){
        Result m = new Result();
        m.setCode(200);
        m.setMsg(msg);
        m.setData(data);
        return m;
    }
    public static Result success(int code,String mess,Object data){
        Result m= new Result();
        m.setCode(code);
        m.setMsg(mess);
        m.setData(data);
        return m;
    }
    public static Result fail(String msg) {
        Result m = new Result();
        m.setCode(400);
        m.setData(null);
        m.setMsg(msg);
        return m;
 }
    public static Result fail(String msg,Object data) {
        Result m = new Result();
        m.setCode(400);
        m.setData(data);
        m.setMsg(msg);
        return m;
    }
    public static Result fail(int code,String msg, Object data) {
        Result m = new Result();
        m.setCode(code);
        m.setData(data);
        m.setMsg(msg);
        return m;
 }

}
